package com.lagou.task1;

import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class Task1Reducer extends Reducer<Task1BaseSort, NullWritable, Text,NullWritable> {
    Text k = new Text();
    int i = 1; //用来记录排名
    @Override
    protected void reduce(Task1BaseSort key, Iterable<NullWritable> values, Reducer<Task1BaseSort, NullWritable, Text, NullWritable>.Context context) throws IOException, InterruptedException {
        //可能有相同分数的 需要循环value
        for ( NullWritable value : values ){
            //组装成需要的格式  排名 分数
            k.set(i+"\t"+key.toString());
            i++;
            context.write(k,value);
        }
    }
}
